-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Register post terms variations on taxonomy registration #56080
Register post terms variations on taxonomy registration #56080
Conversation
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
@draganescu Could you please have a look at this as well? It's pretty much the same as #54801, but for the post-terms block. |
38c3bc1
to
e61364f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, I found myself wondering if unregistering before the block registration needs anything but it does not since once unregistered the tyeps won't exist for the block registration to build variations on them.
👏🏻
Depending on what you get on the previous core ticket (if we need to port this in any way) this PR is subject to the same conclusions. |
2a1a262
to
eba6100
Compare
Updated the PR to be similar to the changes in #56952 and work with the new private Also FYI: According to this comment in 56100 no backport is required for phpunit tests from blocks. Since this PR is the same but for the post-terms block, it's my understanding no backporting is required either. |
eba6100
to
a448131
Compare
@gaambo what happened with this one? I see you closed it but what's the replacement? |
@draganescu I want to see which way it goes for the navigation link block and when that's settled I will do the same for the post-terms block, since it's pretty similar and quick to do then. |
FYI: this was already fixed in 2c247e2 via the new |
What?
This solves the issue from #52569 where custom taxonomies registered after
init
priority 10 are not taken into account for the post-terms blocks variations.Why?
See #52569 - server side function runs too early to make sure it gets all custom taxonomies/post types by plugins, themes etc..
How?
Similar to #54801 (which does the same thing for the navigation link block)
Variations for all taxonomies registered until
register_block_core_post_terms
(at init priority 10) are registered directly in here. For all taxonomies registered after that, actions are added toregistered_taxonomy
, which will register variations during taxonomy registration.We can't use the second approach for all taxonomies, because some of them (eg builtin ones) are registered before the post terms block is registered, therefore variations can't yet be added.
I'm directly adding the variation on the WP_Block_Type object from WP_Block_Type_Registry, because there's no API for registering variations in PHP (yet).
Testing Instructions
Manual testing
Taxonomy
Important: Set the name/label or the block variation is called Post Link.
Important: change add_action priority to something higher than 10 (eg 11) - when using something lower it already works in trunk.
3. Go into site- or post-editor (for the post type post)
4. try to search for a block named like the custom taxonomy (eg "Courses").
5. Block is available
Automated testing
Run
npm run test:unit:php:base -- --filter Block_Post_Terms_Variations_Test
Testing Instructions for Keyboard
Screenshots or screencast